/** @defgroup tool Tool
 * @{
 */

/*
 * Application\Inc\tool.h
 *
 * Cargo tool function
 *
 * Author: Chao-Chi Kuo <chaochi_kuo@systech.com.tw>
 * Copyright (c) 2010 SYSTEMS & TECHNOLOGY CORP. <http://www.systech.com.tw/>
 * All rights reserved.
 *
 * Modifications:
 * 2009/11/18 Chao-Chi Kuo	first implemetation
 *
 * $Id: tool.h 219 2010-08-31 07:51:49Z chaochi_kuo $
 */
#ifndef __TOOL_H_
#define __TOOL_H_

#ifdef  __cplusplus
extern "C" {
#endif		/* __cplusplus */

#include "type.h"

extern int atoh(char *buf);
extern int xatoi(char *buf);
extern unsigned long long xatoll(char *buf);

extern int xtoupper(int ch);

extern unsigned char Calc_CheckSum(char *buf, unsigned short len);

extern int Chk_Num_String(char *buf);
extern int Chk_Hex_String(char *buf);

extern int GetStringItem(char *buf, char *dest, unsigned char idx);

extern unsigned long TimeToUnix(DATE_TIME dtime);
extern void UnixToTime(unsigned long utime, DATE_TIME *dtime);

extern unsigned char octstr_get_char(char *buf);
extern void char_get_octstr(char *buf, unsigned char byte);

extern void assert_malloc(void *buf);
extern void assert_free(void);
extern unsigned long CalcDistanceInMeter(double lat1, double long1, double lat2, double long2);
extern int Check_Time_up(unsigned long current_time, unsigned long chk_time);

extern int Check_Heading_Over(float head_1, float head_2, unsigned short th);

unsigned short GetADC1Channel(unsigned char chanel);
void Delay_Sec(unsigned short d_sec);
void Delay_millisecond(unsigned short d_ms);

int GetStringSetItem(char *buf, char *dest, unsigned int maxLen_dest, unsigned char setChar,unsigned char idx);
#ifdef __cplusplus
}
#endif	/* __cplusplus */
#endif	/* __TOOL_H_ */
/** @} */